﻿/*
 * NetXtcpConnection.h
 *
 */
#ifndef __GDK_NETXTCPCONNECTION_H__
#define __GDK_NETXTCPCONNECTION_H__

#include <gdk/net/Socket.h>
#include <gdk/net/XtcpStream.h>
#include <gdk/net/NetEvent.h>
#include <gdk/net/NetConnection.h>


namespace gdk
{

	class GDK_NET_EXPORT NetXtcpConnection : public XtcpStream, public NetConnection
	{
		DECLARE_CLASS_HANDLE(NetXtcpConnection)
		DECLARE_CLASS_INSTANCE(NetXtcpConnection)

	private:
		bool	_error;
		bool	_connected;
		bool	_isBlocking;

	private:
		NetXtcpConnection(void);
		~NetXtcpConnection(void);

	public:
		virtual void onTick(uint32_t timeSinceLastTick);
		virtual bool attach(NetTcpConnection* conn);
		virtual void close(void);
		virtual void exit(void);
		//--------------------------------------------

	public:
		__INLINE__ bool isConnected(void) const { return getConnectionState() == CONNECTED; } //检查网络是否连接
		//--------------------------------------------
	};
	typedef NetXtcpConnection::Handle	NetXtcpConnectionPtr;


} //namespace gdk


#endif //__GDK_NETXTCPCONNECTION_H__
